﻿using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace TuLing.Blazor.Migrations
{
    public partial class removeNavi23444 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<long>(
                name: "CustomerId",
                table: "BuyOrders",
                type: "INTEGER",
                nullable: false,
                defaultValue: 0L);

            migrationBuilder.AddColumn<string>(
                name: "ProductCode",
                table: "BuyOrderDetails",
                type: "TEXT",
                nullable: true);

            migrationBuilder.AddColumn<long>(
                name: "ProductId",
                table: "BuyOrderDetails",
                type: "INTEGER",
                nullable: false,
                defaultValue: 0L);

            migrationBuilder.AddColumn<string>(
                name: "ProductName",
                table: "BuyOrderDetails",
                type: "TEXT",
                nullable: true);

            migrationBuilder.CreateIndex(
                name: "IX_BuyOrders_CustomerId",
                table: "BuyOrders",
                column: "CustomerId");

            migrationBuilder.CreateIndex(
                name: "IX_BuyOrderDetails_ProductId",
                table: "BuyOrderDetails",
                column: "ProductId");

            migrationBuilder.AddForeignKey(
                name: "FK_BuyOrderDetails_Products_ProductId",
                table: "BuyOrderDetails",
                column: "ProductId",
                principalTable: "Products",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_BuyOrders_Customers_CustomerId",
                table: "BuyOrders",
                column: "CustomerId",
                principalTable: "Customers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_BuyOrderDetails_Products_ProductId",
                table: "BuyOrderDetails");

            migrationBuilder.DropForeignKey(
                name: "FK_BuyOrders_Customers_CustomerId",
                table: "BuyOrders");

            migrationBuilder.DropIndex(
                name: "IX_BuyOrders_CustomerId",
                table: "BuyOrders");

            migrationBuilder.DropIndex(
                name: "IX_BuyOrderDetails_ProductId",
                table: "BuyOrderDetails");

            migrationBuilder.DropColumn(
                name: "CustomerId",
                table: "BuyOrders");

            migrationBuilder.DropColumn(
                name: "ProductCode",
                table: "BuyOrderDetails");

            migrationBuilder.DropColumn(
                name: "ProductId",
                table: "BuyOrderDetails");

            migrationBuilder.DropColumn(
                name: "ProductName",
                table: "BuyOrderDetails");
        }
    }
}
